package main

import (
	"fmt"
	"time"
)

// select跟等待多个cannel通道，将goroutines和 channel与select相结合
func main() {

	c1 := make(chan string)
	c2 := make(chan string)

	go func() {
		time.Sleep(time.Second * 1)
		c1 <- "666"
	}()

	go func() {
		time.Sleep(time.Second * 2)
		c2 <- "888"
	}()

	for i := 0; i < 2; i++ {
		select {
		case msg := <-c1:
			fmt.Println(msg)
		case msg2 := <-c2:
			fmt.Printf(msg2)
		}
	}
}
